package com.aiyige.page.publish.selectinterest.adapter;

import android.graphics.Typeface;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.publish.selectinterest.model.PublishInterestItem;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by usera on 2017/11/6.
 */

public class PublishInterestAdapter extends BaseQuickAdapter<PublishInterestItem, PublishInterestAdapter.ViewHolder> {


    public PublishInterestAdapter() {
        super(R.layout.publish_interest_item, new LinkedList<PublishInterestItem>());
    }

    @Override
    protected void convert(ViewHolder helper, PublishInterestItem item) {
        helper.bindData(item);
    }


    public static class ViewHolder extends BaseViewHolder {
        @BindView(R.id.titleTv)
        TextView titleTv;
        @BindView(R.id.addIv)
        ImageView addIv;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(PublishInterestItem data) {
            switch (data.getType()) {
                case PublishInterestItem.TYPE_ADD:
                    addIv.setVisibility(View.VISIBLE);
                    break;
                case PublishInterestItem.TYPE_NORMAL:
                    addIv.setVisibility(View.INVISIBLE);
                    titleTv.setText(data.getTitle());
                    titleTv.setTypeface(null, Typeface.NORMAL);
                    break;
                case PublishInterestItem.TYPE_SELECT_ALL:
                    addIv.setVisibility(View.INVISIBLE);
                    titleTv.setText(R.string.all);
                    titleTv.setTypeface(null, Typeface.BOLD);
                    break;
            }


        }
    }
}
